/*
 * Copyright (C) 2009, 2010 M. Homs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//
// OOP tests
//
var def = function(value, defaultValue) {
	return value === undefined ? defaultValue : value;
};

function Person(name, age) {

	this.name = def(name, "unnamed");
	this.age = def(age, -1);

	this.toString = function() {
		return this.name + "/" + this.age;
	};
};

function Engineer(name, age, speciality) {
	this.sup = new Person(name, age);
	this.speciality = def(speciality, "-");

	this.toString = function() {
		return this.sup.toString() + "/" + this.speciality;
	};
};

assert.equals("unnamed/-1", new Person().toString());
assert.equals("m.homs/28", new Person("m.homs", 28).toString());

assert.equals("unnamed/-1/-", new Engineer().toString());
assert.equals("m.homs/28/coder", new Engineer("m.homs", 28, "coder").toString());

